<?php
namespace app\admin\controller;

use think\Cache;
use think\Controller;
use think\View;

class Base extends Controller
{
    /**
     * 清理缓存
     */
    public function clear_cache() {
        \app\api\service\Base::clear_cache();
    }

    /**
     * 图片上传
     */
    public function upload_image() {
        if (isset($_FILES['file'])) {
            $upload_data = \app\api\service\Upload::layim_upload_img();
        } else {
            $upload_data = \app\api\service\Upload::upload_image();
        }

//        dump($data);

        if (input('param.image_type') == 6) { // 编辑器图片上传
            if ($upload_data['code'] ==200) {
                $data = [
                    'code' => 0,
                    'msg' => '上传成功！',
                    'data' => [
                        'src' => $upload_data['path'] . '-700'
                    ]
                ];
            } else {
                $data = [
                    'code' => 1,
                    'msg' => $upload_data['msg'],
                    'data' => [
                        'src' => ''
                    ]
                ];
            }
        }
        return json($data);
    }

    /**
     * 获取验证码
     */
    public function getVerify()
    {
        GetVerify();
    }

    /**
     * 获取短信验证码
     */
    public function get_note_code() {
        $mobile = input('param.mobile');
        $data = \app\api\service\NoteCode::send_code(['mobile' => $mobile]);
        return json($data);
    }
}
